package com.ruoyi.system.util;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

public class FjxlConverter implements Converter<String> {



    @Override
    public Class<?> supportJavaTypeKey() {
        // 支持的Java类型
        return String.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        // 转换后的Excel单元格类型
        return CellDataTypeEnum.STRING;
    }

    @Override
    public WriteCellData<?> convertToExcelData(String value, ExcelContentProperty contentProperty,
                                               GlobalConfiguration globalConfiguration) {

//        TP("图片", 1),
//                SP("视频", 2),
//                YX("影像", 3),
//                YP("音频", 4),
//                SL("矢量", 5),
//                DMSJ("地名数据", 6),
//                WD("文档", 7),
//                ZIP("zip", 8),
//                LSSJ("临时文件", 9);
        // 转换逻辑：1->男，2->女，3->未知，其他值也显示未知
        String sexStr;
        if (value == null) {
            sexStr = "未知";
        } else {
            switch (value) {
                case "1":
                    sexStr = "图片";
                    break;
                case "2":
                    sexStr = "视频";
                    break;
                case "3":
                    sexStr = "影像";
                    break;
                case "4":
                    sexStr = "音频";
                    break;
                case "5":
                    sexStr = "矢量";
                    break;
                case "6":
                    sexStr = "地名数据";
                    break;
                case "7":
                    sexStr = "文档";
                    break;

                default:
                    sexStr = "未知";
            }
        }
        return new WriteCellData<>(sexStr);
    }

}
